
// Change this to something likely to be unique!  Name:Sig format is suggested.
constant PICTSym := '|Stupidguy:Graviton|;

// DON't change this.
constant PICTSoupName := "PICTSoup:OnSet:Graviton";

InstallScript := func(partFrame)
begin

   local Internal := GetStores()[0];
   local theSoup := Internal:GetSoup(PICTSoupName);

   if NOT theSoup then 
   begin
      GetRoot():notify(kNotifyAlert,"PictureDownloader",
         "OnSet is not installed.  Install OnSet and download this package again.");
   end;
   else begin
      local existing := Query(theSoup, { type: 'index, validTest: func(e) e.sym = PICTsym});
      if existing:Entry() then
      begin
         GetRoot():notify(kNotifyAlert,"PictureDownloader",
            "A picture with this name is already installed.");
      end;
      else begin

         local theSoupEntry := { sym: PICTSym, icon:  partFrame.theForm.picture };

         theSoup:Add(EnsureInternal(TotalClone(theSoupEntry)));
         theSoup:Flush();
         BroadcastSoupChange(PICTSoupName);
      end;
   end;

// Finally!  This actually works.

   AddDeferredAction(
      func(id) 
      begin
         local pack := GetPackages();
         local which := ArrayPos(pack,id,0,func(i,p) i = p.id);
         RemovePackage(pack[which]);
      end;
  ,[partFrame.PackageID]);

end;